#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5,mod=1e9+7;
long long dp[N][N][2][4],n,m,sum[N][N][2][4],jc[N],ans; 
string qwq,a,b;
int main()
{
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	cin>>qwq>>b>>a;
	jc[0]=1;
	for(int i=0;i<n;++i)
		if(qwq[i]=='L')
			qwq[i]=0;
		else
			qwq[i]=1;
	for(int i=1;i<=n;++i)
		jc[i]=jc[i-1]*2%mod;
	dp[0][0][0][3]=dp[0][0][1][3]=1;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<=min(i+1ll,m);++j)
		{
			for(int z=0;z<=1;++z)
			{
				for(int p=0;p<=3;++p)
				{
					if(p==0)
					{
						if(j>0) dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j-1][z^1][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j-1][z^1][p]+dp[i][j-1][z^1][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
						dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j][z][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j][z][p]+dp[i][j][z][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
					}
					if(p==1)
					{
						if(a[i+1]=='1')
						{
							if(z==0^qwq[i]){ 
								if(j>0) dp[i+1][j][z][0]=(dp[i+1][j][z][0]+dp[i][j-1][z^1][1])%mod,sum[i+1][j][z][0]=(sum[i+1][j][z][0]+sum[i][j-1][z^1][1]+dp[i][j-1][z^1][1]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][0]=(dp[i+1][j][z][0]+dp[i][j][z][1])%mod,sum[i+1][j][z][0]=(sum[i+1][j][z][0]+sum[i][j][z][1]+dp[i][j][z][1]*jc[n-i]%mod*(z^qwq[i]))%mod; 
							}
							else
							{
								if(j>0) dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j-1][z^1][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j-1][z^1][p]+dp[i][j-1][z^1][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j][z][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j][z][p]+dp[i][j][z][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
						}
						else{
							if(z==0^qwq[i])
							{
								if(j>0) dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j-1][z^1][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j-1][z^1][p]+dp[i][j-1][z^1][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j][z][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j][z][p]+dp[i][j][z][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
						}
					}
					if(p==2)
					{
						if(b[i+1]=='0')
						{
							if(z==1^qwq[i])
							{
								if(j>0) dp[i+1][j][z][0]=(dp[i+1][j][z][0]+dp[i][j-1][z^1][2])%mod,sum[i+1][j][z][0]=(sum[i+1][j][z][0]+sum[i][j-1][z^1][2]+dp[i][j-1][z^1][2]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][0]=(dp[i+1][j][z][0]+dp[i][j][z][2])%mod,sum[i+1][j][z][0]=(sum[i+1][j][z][0]+sum[i][j][z][2]+dp[i][j][z][2]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
							else{
								if(j>0) dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j-1][z^1][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j-1][z^1][p]+dp[i][j-1][z^1][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j][z][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j][z][p]+dp[i][j][z][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
						}
						else{
							if(z==1^qwq[i])
							{
								if(j>0) dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j-1][z^1][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j-1][z^1][p]+dp[i][j-1][z^1][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][p]=(dp[i+1][j][z][p]+dp[i][j][z][p])%mod,sum[i+1][j][z][p]=(sum[i+1][j][z][p]+sum[i][j][z][p]+dp[i][j][z][p]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
						}
					}
					if(p==3)
					{
						if(b[i+1]=='0'&&a[i+1]=='1')
						{
							if(z==1^qwq[i])
							{
								if(j>0) dp[i+1][j][z][1]=(dp[i+1][j][z][1]+dp[i][j-1][z^1][3])%mod,sum[i+1][j][z][1]=(sum[i+1][j][z][1]+sum[i][j-1][z^1][3]+dp[i][j-1][z^1][3]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][1]=(dp[i+1][j][z][1]+dp[i][j][z][3])%mod,sum[i+1][j][z][1]=(sum[i+1][j][z][1]+sum[i][j][z][3]+dp[i][j][z][3]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
							else{
								if(j>0) dp[i+1][j][z][2]=(dp[i+1][j][z][0]+dp[i][j-1][z^1][3])%mod,sum[i+1][j][z][2]=(sum[i+1][j][z][2]+sum[i][j-1][z^1][3]+dp[i][j-1][z^1][3]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][2]=(dp[i+1][j][z][2]+dp[i][j][z][3])%mod,sum[i+1][j][z][2]=(sum[i+1][j][z][2]+sum[i][j][z][3]+dp[i][j][z][3]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
						}
						if(b[i+1]==a[i+1]) 
						{
							if(z==(b[i+1]-'0')^qwq[i])
							{
								if(j>0) dp[i+1][j][z][3]=(dp[i+1][j][z][3]+dp[i][j-1][z^1][3])%mod,sum[i+1][j][z][3]=(sum[i+1][j][z][3]+sum[i][j-1][z^1][3]+dp[i][j-1][z^1][3]*jc[n-i]%mod*(z^qwq[i]))%mod;
								dp[i+1][j][z][3]=(dp[i+1][j][z][3]+dp[i][j][z][3])%mod,sum[i+1][j][z][3]=(sum[i+1][j][z][3]+sum[i][j][z][3]+dp[i][j][z][3]*jc[n-i]%mod*(z^qwq[i]))%mod;
							}
						}
					}
				}
			}
		}
	}
	for(int z=0;z<=1;++z)
		for(int p=0;p<=3;++p)
			ans=(ans+sum[n][m][z][p])%mod;
	cout<<ans;
}
